home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 4BR8GD (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.4 KB  |  65 lines

  1. package com.sun.java.swing.plaf.basic;
  2.  
  3. import com.sun.java.swing.AbstractAction;
  4. import java.awt.Dimension;
  5. import java.awt.Rectangle;
  6. import java.awt.event.ActionEvent;
  7. import java.io.Serializable;
  8.  
  9. class BasicTreeUI$TreePageAction extends AbstractAction implements Serializable {
  10.    // $FF: synthetic field
  11.    BasicTreeUI this$0;
  12.    private int direction;
  13.  
  14.    // $FF: synthetic method
  15.    public BasicTreeUI$TreePageAction(BasicTreeUI this$0, int direction, String name) {
  16.       super(name);
  17.       this.this$0 = this$0;
  18.       this.direction = direction;
  19.    }
  20.  
  21.    public void actionPerformed(ActionEvent e) {
  22.       if (this.this$0.tree != null && this.this$0.getRowCount() > 0 && this.this$0.treeSelectionModel != null) {
  23.          Dimension maxSize = this.this$0.tree.getSize();
  24.          Rectangle visRect = this.this$0.tree.getVisibleRect();
  25.          int maxVisY = Math.max(0, maxSize.height - visRect.height);
  26.          int selIndex;
  27.          if (this.direction == -1) {
  28.             selIndex = this.this$0.getMinSelectionRow();
  29.          } else {
  30.             selIndex = this.this$0.getMaxSelectionRow();
  31.          }
  32.  
  33.          if (selIndex != -1) {
  34.             Rectangle selRect = this.this$0.getRowBounds(selIndex);
  35.             if (this.direction == -1) {
  36.                visRect.y = Math.max(0, selRect.y + selRect.height - visRect.height);
  37.             } else {
  38.                visRect.y = Math.min(maxVisY, selRect.y);
  39.             }
  40.          } else {
  41.             visRect.y = Math.min(maxVisY, visRect.y + visRect.height * this.direction);
  42.          }
  43.  
  44.          int newIndex;
  45.          if (this.direction == 1) {
  46.             newIndex = this.this$0.getClosestRowForLocation(visRect.x, visRect.y + visRect.height - 1);
  47.             Rectangle var8 = this.this$0.getRowBounds(newIndex);
  48.             visRect.y = Math.min(maxVisY, var8.y + var8.height - visRect.height);
  49.          } else {
  50.             newIndex = this.this$0.getClosestRowForLocation(visRect.x, visRect.y + 1);
  51.             Rectangle var9 = this.this$0.getRowBounds(newIndex);
  52.             visRect.y = Math.min(maxVisY, var9.y);
  53.          }
  54.  
  55.          this.this$0.tree.scrollRectToVisible(visRect);
  56.          this.this$0.tree.setSelectionRow(newIndex);
  57.       }
  58.  
  59.    }
  60.  
  61.    public boolean isEnabled() {
  62.       return this.this$0.tree != null && this.this$0.tree.isEnabled();
  63.    }
  64. }
  65.